package com.hy.mydesktop.client.component.factory;

import com.extjs.gxt.ui.client.widget.layout.AccordionLayout;
import com.hy.mydesktop.client.component.meta.AccordionLayoutModelEnum;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaNodeModel;

/**
 * 
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-8-31；时间：下午04:03:09</li>
 * <li>类型名称：AccordionLayoutFactory</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
public class AccordionLayoutFactory {
	
	/**
	 * 
	 * <ul>
	 * <li>方法含义：创建AccordionLayout布局</li>
	 * <li>方法作者：汤莉</li>
	 * <li>编写日期：2010-8-31；时间：下午下午04:03:58</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @param gxtComponentMetaNodeModel
	 * @return
	 */
	public static AccordionLayout createAccordionLayout(GxtComponentMetaNodeModel gxtComponentMetaNodeModel){
		return configureAccordionLayout(gxtComponentMetaNodeModel);
	}
	
	/**
	 * 
	 * <ul>
	 * <li>方法含义：配置AccordionLayout的相关属性</li>
	 * <li>方法作者：汤莉</li>
	 * <li>编写日期：2010-8-31；时间：下午下午04:04:40</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @param gxtComponentMetaNodeModel
	 * @return
	 */
	private static AccordionLayout configureAccordionLayout(GxtComponentMetaNodeModel gxtComponentMetaNodeModel){
		
		AccordionLayout layout=createDefaultAccordionLayout();
		
		if(gxtComponentMetaNodeModel.get(AccordionLayoutModelEnum.AUTOWIDTH.name().toLowerCase())!=null){
			
			layout.setAutoWidth(Boolean.parseBoolean((String)gxtComponentMetaNodeModel.get(AccordionLayoutModelEnum.AUTOWIDTH.name().toLowerCase())));
		}
		if(gxtComponentMetaNodeModel.get(AccordionLayoutModelEnum.FILL.name().toLowerCase())!=null){
			
			layout.setFill(Boolean.parseBoolean((String)gxtComponentMetaNodeModel.get(AccordionLayoutModelEnum.FILL.name().toLowerCase())));
		}
		if(gxtComponentMetaNodeModel.get(AccordionLayoutModelEnum.HIDECOLLAPSETOOL.name().toLowerCase())!=null){
			
			layout.setHideCollapseTool(Boolean.parseBoolean((String)gxtComponentMetaNodeModel.get(AccordionLayoutModelEnum.HIDECOLLAPSETOOL.name().toLowerCase())));
		}
		if(gxtComponentMetaNodeModel.get(AccordionLayoutModelEnum.TITLECOLLAPSE.name().toLowerCase())!=null){
			
			layout.setTitleCollapse(Boolean.parseBoolean((String)gxtComponentMetaNodeModel.get(AccordionLayoutModelEnum.TITLECOLLAPSE.name().toLowerCase())));
		}
		
		return layout;
	}
	
	/**
	 * 
	 * <ul>
	 * <li>方法含义：默认的AccordionLayout</li>
	 * <li>方法作者：汤莉</li>
	 * <li>编写日期：2010-8-31；时间：下午下午04:05:28</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @return
	 */
	private static AccordionLayout createDefaultAccordionLayout(){
		AccordionLayout layout=new AccordionLayout();
		
		return layout;
	}
}
